package com.heima.admin;

import org.apache.commons.lang.RandomStringUtils;
import org.junit.jupiter.api.Test;
import org.springframework.util.DigestUtils;

public class md5 {
    public static void main(String[] args) {
        //md5加密  DegestUtils：spring框架提供的工具类
        String md5Str = DigestUtils.md5DigestAsHex("abc".getBytes());
        System.out.println(md5Str);//900150983cd24fb0d6963f7d28e17f72



        //uername:zhangsan  password:123   salt:随时字符串
        String salt = RandomStringUtils.randomAlphanumeric(10);//获取一个10位的随机字符串


        System.out.println(salt); // 124ewfdsfdsd
        String pswd = "123"+salt;
        String saltPswd = DigestUtils.md5DigestAsHex(pswd.getBytes());
        System.out.println(saltPswd);


    }

   @Test
    public void mp51(){


       String salt = "123abc";
       String pswd = "251b57454f0c600aa20a51ab03756845"+salt;
       String saltPswd = DigestUtils.md5DigestAsHex(pswd.getBytes());

       System.out.println(saltPswd);



   }


}
